# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=firmware-mod-kit
pkgver=184.b31fcb0
pkgrel=1
groups=('blackarch' 'blackarch-firmware')
pkgdesc='Modify firmware images without recompiling.'
url='https://github.com/rampageX/firmware-mod-kit'
arch=('x86_64' 'aarch64')
license=('MIT')
depends=('python-magic')
makedepends=('gcc' 'git' 'make')
source=("$pkgname::git+https://github.com/rampageX/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build(){
  cd "$pkgname/src"

  ./configure --prefix=/usr

  make
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/share/$pkgname"
  install -dm 755 "$pkgdir/usr/share/doc/$pkgname"

  install -m 755 *.sh "$pkgdir/usr/share/$pkgname/"
  install -m 644 *.inc "$pkgdir/usr/share/$pkgname/"
  install -m 644 firmware_mod_kit_version.txt "$pkgdir/usr/share/$pkgname/"

  install -m 644 *.htm "$pkgdir/usr/share/doc/$pkgname/"
  install -m 644 *.md "$pkgdir/usr/share/doc/$pkgname/"

  cp -a --no-preserve=ownership ipk_template other-scripts src \
    "$pkgdir/usr/share/$pkgname/"
}

